package tt.com.carmanager.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import tt.com.carmanager.mapper.CarManagerMapper;
import tt.com.carmanager.mapper.ClassesTeamMapper;
import tt.com.carmanager.service.CarManagerService;
import tt.com.carmanager.service.FuneralDriverTaskService;
import tt.com.common.enums.TaskStatusEnum;
import tt.com.common.model.Car;
import tt.com.common.model.ClassesTeam;
import tt.com.common.model.DriveTask;
import tt.com.common.model.Team;
import tt.com.common.util.ObjectUtil;

import java.util.Date;
import java.util.List;

@Service
public class CarManagerServiceImpl extends ServiceImpl<CarManagerMapper, Car> implements CarManagerService {
    //引入service
    @Autowired
    private FuneralDriverTaskService funeralDriverTaskService;

    @Autowired
    private ClassesTeamMapper classesTeamMapper;

    @Override
    public ResponseEntity appointmentCar(DriveTask task) {
        if (!ObjectUtil.objectIsNull(task)) {
            return null;
        }
        //判断逝者是否存在
        //ClassesTeam id = classesTeamService.getById(1L);
        /*if (id == null){
            return null;
        }*/
        task.setDataStatus(1);
        task.setCreateUserId("1");
        task.setCreateTime(new Date());
        task.setLastUpdateTime(task.getCreateTime());
        task.setLastUpdateUserId(task.getCreateUserId());
        //定义状态
        task.setTaskStatus(TaskStatusEnum.NOT_STARTED);
        boolean save = funeralDriverTaskService.save(task);
        if (!save){
            return null;
        }
        return null;
    }

    @Override
    public List<Team> printTeamByDay(Date startDate, Date endDate) {
        return classesTeamMapper.searchByDay(startDate, endDate);
    }

    @Override
    public List<ClassesTeam> printPDFByDate(Date startDate, Date endDate) {
        List<ClassesTeam> teams = classesTeamMapper.printPDFByTeamDay(startDate, endDate);
        return teams;
    }

}
